<template>
  <div>
    <el-button
      type="primary"
      icon="el-icon-circle-plus-outline"
      @click="addItem"
      >添加</el-button
    >
    <list ref="list" @edit="edit"></list>
    <info ref="info" :info="info" @update="update"></info>
  </div>
</template>

<script>
import list from "./list.vue";
import info from "./info.vue";
export default {
  data() {
    return {
      info: {
        isShow: false,
        title: "添加",
      },
    };
  },
  components: {
    list,
    info,
  },
  methods: {
    addItem() {
      // 打开新增的弹窗
      this.info.isShow = true;
      this.info.title = "添加";
      this.$refs.info.setValue({
        rolename: "",
        menus: '',
        status: 1,
      });
    },
    edit(data) {
      // 打开修改的弹窗
      this.info.isShow = true;
      this.info.title = "修改";
      this.$refs.info.setValue(data);
    },
    update() {
      // info组件新增成功后，通知list重新获取最新数据
      this.$refs.list.getMenuList();
    },
  },
};
</script>

<style>
</style>